﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Bluebunnie
{
    /// <summary>
    /// Interaction logic for TabHeader.xaml
    /// </summary>
    public partial class TabHeader : UserControl
    {
        RoutedEventHandler saveAction;

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(TabHeader), new UIPropertyMetadata(string.Empty));
        
        public TabHeader(string text)
        {
            InitializeComponent();
            DataContext = this;

            Text = text;
        }

        public TabHeader(string text, RoutedEventHandler saveAction)
        {
            this.saveAction = saveAction;

            InitializeComponent();
            DataContext = this;

            Text = text;
        }

        private void Close_Click(object sender, RoutedEventArgs e)
        {
            Shell.Current.Close(Text);
        }

        private void SaveAndContinue_Click(object sender, RoutedEventArgs e)
        {
            saveAction(this, new RoutedEventArgs());
        }

        private void SaveAndClose_Click(object sender, RoutedEventArgs e)
        {
            saveAction(this, new RoutedEventArgs());
            Shell.Current.Close(Text);
        }
    }
}
